package pl.edu.pw.elka.tinyrepo.gate.descriptor;

import java.io.FileNotFoundException;

import java.util.StringTokenizer;

import pl.edu.pw.elka.tinyrepo.common.HTTPHeaderType;
import pl.edu.pw.elka.tinyrepo.common.exceptions.ContentAlreadyExistException;
import pl.edu.pw.elka.tinyrepo.common.exceptions.WrongPathException;
import pl.edu.pw.elka.tinyrepo.gate.descriptor.*;
public class CatalogDescriptorTest {

   /**
    * @param args
    */
   public static void main(String[] args) {
      CatalogDescriptor root = new CatalogDescriptor();
      FileDescriptor file = new FileDescriptor(1, "1", 10L);
      CatalogDescriptor katalog = new CatalogDescriptor();
      FileDescriptor f;
      try {
         root.addChildDescriptor(katalog, "/a");
         root.addChildDescriptor(file, "/a/plik");
         CatalogDescriptor k2 = new CatalogDescriptor(); 
         CatalogDescriptor k3 = new CatalogDescriptor();
         root.addChildDescriptor(k2, "/a/a2/");
         root.addChildDescriptor(file, "/a/a2/plik");
         root.addChildDescriptor(k3, "/b");
         root.addChildDescriptor(file, "/");
         System.out.println("Przed usunieciem.");
         CatalogDescriptor.printCatalog("/", root);
         root.removeChildDescriptor("a/a2/plik");
         root.moveChildDescriptor("/b", "/a/a2/b");
         System.out.println("Po usunieciu");
         CatalogDescriptor.printCatalog("/", root);
//         System.out.println(root.childs);
      } catch (FileNotFoundException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
      } catch (WrongPathException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
      } catch (ContentAlreadyExistException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
      }
      //testy 2
      StringTokenizer t = new StringTokenizer("Content-length: 170 120");
      System.out.println(t.nextToken());
      System.out.println(t.nextToken(""));
      // testy 3
      
      HTTPHeaderType header = HTTPHeaderType.CONTENT_LENGTH;
      System.out.println(header.isProperValue("43 43")); // dla isProperValue
      header = HTTPHeaderType.CONTENT_TYPE;
      System.out.println(header.isProperValue("dsad53fa"));
      StringTokenizer t2 = new StringTokenizer("test", "/");
      System.out.println(t2.countTokens());
      // testy
   }

}
